package com.quectel.grid.controller.grid;


import com.quectel.business.common.grid.GridMemberEvaluateBusiness;
import com.quectel.core.module.grid.dto.GridMemberDto;
import com.quectel.core.module.grid.dto.GridMemberEvaluateDto;
import com.quectel.core.module.grid.service.GridMemberEvaluateService;
import com.quectel.grid.controller.BaseController;
import com.quectel.grid.util.SessionHolder;
import com.quectel.util.common.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bob
 * @email bob.yu@quectel.com
 * @date 2023/02/16 0:45
 */
@RestController
@RequestMapping("gridMemberEvaluate")
@Tag(name = "GridMemberEvaluateController", description = "网格员评估相关api")
public class GridMemberEvaluateController extends BaseController {

    @DubboReference
    private GridMemberEvaluateService gridMemberEvaluateService;
    @Autowired
    private GridMemberEvaluateBusiness gridMemberEvaluateBusiness;

    /**
     * 通过年份查询评估结果
     *
     * @param assessYear 评估年份
     * @return
     */
    @GetMapping("getInfoByAssessYear")
    @Operation(summary = "通过年份查询评估结果")
    public Response<GridMemberEvaluateDto> getInfoByAssessYear(@Parameter(description = "评估年份") @RequestParam String assessYear) {
        GridMemberDto gridMember = SessionHolder.getGridMember();
        assert gridMember != null;
        return Response.<GridMemberEvaluateDto>ok().wrap(gridMemberEvaluateService.selectOneByMemberIdAndAssessYear(gridMember.getId(), assessYear));
    }

}
